package nl.fonfolio.view {
	import flash.events.MouseEvent;	
	import flash.display.Sprite;

	import caurina.transitions.Tweener;
	
	import flash.display.MovieClip;
	
	import nl.fonfolio.core.Fonfolio;	

	/**
	 * @author lindy
	 */
	public class Menu extends Sprite {
		public var menu : MovieClip;
		public var menu_btn : MovieClip;
		private var inY : Number = 10;
		private var outY : Number = -218;
		private var fonfolio:Fonfolio;

		public function Menu(fonfolio:Fonfolio) {
			this.fonfolio = fonfolio;
			this.menu_btn.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
			this.addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
			this.menu.login_btn.addEventListener(MouseEvent.CLICK, openLogin)
			this.menu.search_btn.addEventListener(MouseEvent.CLICK, openSearch)
			this.menu.dashboard_btn.addEventListener(MouseEvent.CLICK, openDashboard)
		}
		
		private function openDashboard(event : MouseEvent) : void {
			trace("MENU: Dashboard clicked");
			this.fonfolio.openDashboard();
		}

		private function openSearch(event : MouseEvent) : void {
			trace("MENU: Search clicked");
			this.fonfolio.openSearch();
		}

		private function openLogin(event : MouseEvent) : void {
			trace("MENU: Login clicked");
			this.fonfolio.openLogin();
		}

		private function onMouseOut(event : MouseEvent) : void {
			trace("out");
			Tweener.addTween(this.menu,{y:this.inY, time:0.3, transition:"easeInQuart"});
			Tweener.addTween(this.menu_btn,{rotation:0, time:0.3, transition:"easeInQuart"});
		}

		private function onMouseOver(event : MouseEvent) : void {
			trace("in");
			Tweener.addTween(this.menu,{y:this.outY, time:0.3, transition:"easeOutQuart"});
			Tweener.addTween(this.menu_btn,{rotation:180, time:0.3, transition:"easeOutQuart"});
		}
	}
}
